{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"https://raw.githubusercontent.com/Qiskit/qiskit-tutorials/master/images/qiskit-heading.png\" alt=\"Note: In order for images to show up in this jupyter notebook you need to select File => Trusted Notebook\" width=\"500 px\" align=\"left\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## _*Two-qubit Quantum Random Access Coding (QRAC)*_ \n",
    "\n",
    "The latest version of this notebook is available on https://github.com/QISKit/qiskit-tutorial.\n",
    "\n",
    "***\n",
    "### Contributors\n",
    "Rudy Raymond, Takashi Imamichi\n",
    "\n",
    "### Qiskit Package Versions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'qiskit': '0.10.3',\n",
       " 'qiskit-terra': '0.8.1',\n",
       " 'qiskit-ignis': '0.1.1',\n",
       " 'qiskit-aer': '0.2.1',\n",
       " 'qiskit-ibmq-provider': '0.2.2',\n",
       " 'qiskit-aqua': '0.5.1'}"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import qiskit\n",
    "qiskit.__qiskit_version__"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Introduction\n",
    "\n",
    "As seen [here](single-qubit_quantum_random_access_coding.ipynb), thanks to the superposition of quantum states, by QRAC a single qubit can be used to encode up to 3 bits $x_1x_2x_3$ of information so that any one bit $x_i$ can be recovered with probability at least $0.78$. What happens if we have more qubits? As more qubits are available, we can go beyond a simple combination of QRAC of individual qubit by leveraging the entanglement. With two qubits, we can clearly use $(3,1)$-QRAC on each qubit and obtain a $(6,2)$-QRAC. Can we encode more bits? The answer is yes. Notice that two classical bits can be used to encode only up to 3 bits of information in the random access coding. \n",
    "\n",
    "We will show a $(7,2)$-QRAC following Example 4 in the paper [here](http://iopscience.iop.org/article/10.1088/1367-2630/8/8/129/meta). The success probability is $0.54$, which is slightly better than random guessing. The $(7,2)$-QRAC in the example uses [*quantum mixed states*](https://en.wikipedia.org/wiki/Quantum_state#Mixed_states) to mix two $(3,1)$-QRACs, for encoding the first six bits $x_1x_2x_3x_4x_5x_6$, with the encoding of the seventh bit $x_7$. Namely, the mixed state contains, with probability $\\alpha \\equiv \\frac{6}{7+\\sqrt{3}}$, two $(3,1)$-QRACs encoding the first six bits, and the encoding of $x_7$ that entangles the first qubit and the second qubit (if $x_7 = 0$, the two qubits become $|00\\rangle + |11\\rangle$, or $|01\\rangle+|10\\rangle$ otherwise) with probability $1 - \\alpha$.\n",
    "\n",
    "The *quantum mixed states* used in the $(7,2)$-QRAC can be created by the sender using a series of unitary operations on three qubits by using the first qubit to control the mixing probability. The sender then sends the last two qubits (the second and third ones) that are used by the receiver to decode his choice of bit. \n",
    "\n",
    "The procedure is as follows. First, the sender prepares three qubits $|000\\rangle$ and transforms them to obtain\n",
    "\n",
    "\\begin{eqnarray}\n",
    "|000\\rangle &\\xrightarrow{U(1.187, 0, 0)}& \\sqrt{\\alpha} |000\\rangle + \\sqrt{1 - \\alpha} |100\\rangle,\n",
    "\\end{eqnarray}\n",
    "\n",
    "where $U(1.187,0,0)$ is the single-qubit rotation gate applied to the first qubit. Notice that $\\cos(1.187/2) \\approx \\sqrt\\alpha$.\n",
    "\n",
    "Next, the sender uses her first qubit to control the value of the second and third qubits. When, the first qubit is $0$, the sender encodes the $x_1x_2x_3$ into the second qubit, and the $x_4x_5x_6$ into the third qubit. This means, she performs the following transformation (note that $V$ is conditioned on $x_1x_2x_3x_4x_5x_6$), \n",
    "\n",
    "\\begin{eqnarray}\n",
    "|000\\rangle &\\xrightarrow{V}& |0\\rangle |\\phi\\left(x_1x_2x_3\\right)\\rangle |\\phi\\left(x_4x_5x_6\\right)\\rangle,\n",
    "\\end{eqnarray}\n",
    "\n",
    "where $|\\phi\\left(xyz\\right)\\rangle$ is the $(3,1)$-QRAC of $xyz$. Otherwise, when the second qubit is $1$, the sender encodes the $x_7$ by using the Bell states. Namely, by entangling the second and the third qubit so that when $x_7 = 0$ the second and third qubits are the same, and when $x_7 = 1$ they are different, as follows. \n",
    "\n",
    "\\begin{eqnarray}\n",
    "|100\\rangle & \\xrightarrow{\\mbox{if}~x_7 = 0} & |1\\rangle\\left( \\frac{1}{\\sqrt{2}}|00\\rangle + \\frac{1}{\\sqrt{2}} |11\\rangle\\right) \\equiv |1\\rangle|\\xi(0)\\rangle \\\\\n",
    "|100\\rangle & \\xrightarrow{\\mbox{if}~x_7 = 1} & |1\\rangle\\left(\\frac{1}{\\sqrt{2}}|01\\rangle + \\frac{1}{\\sqrt{2}} |10\\rangle\\right) \\equiv |1\\rangle|\\xi(1)\\rangle \n",
    "\\end{eqnarray}\n",
    "\n",
    "The second and third qubits are then sent to the receiver, who performs measurement to obtain his desired bit. Notice that because the receiver does not have the first qubit, the state of his two qubits is the mixed state as below\n",
    "\n",
    "$$\n",
    "\\rho\\left(x_1x_2\\ldots x_7\\right) = \\alpha |\\phi\\left(x_1x_2x_3\\right)\\rangle\\langle\\phi\\left(x_1x_2x_3\\right)| \\otimes |\\phi\\left(x_4x_5x_6\\right)\\rangle\\langle\\phi\\left(x_4x_5x_6\\right)|   + (1-\\alpha) |\\xi\\left(x_7\\right)\\rangle\\langle\\xi\\left(x_7\\right)| \n",
    "$$\n",
    "\n",
    "Now, the receiver can recover any one bit of $x_1x_2\\ldots x_7$ as follows. If he wants to obtain any one bit of $x_1x_2x_3$, he measures his first qubit using the measurements of $(3,1)$-QRAC. Similarly, if he wants to obtain any one bit of $x_4x_5x_6$, he measures his second qubit using the measurements of $(3,1)$-QRAC. Finally, if he wants to obtain the seventh bit $x_7$, he measures both qubits and concludes that $x_7 = 0$ if the outcome of the measurement is the same (they are both $0$ or $1$), or $x_7 = 1$ otherwise.\n",
    "\n",
    "Now, we show how to perform the experiment on the above $(7,2)$-QRAC using the IBM Q Experience. We first prepare the environment."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# useful math functions\n",
    "from math import pi, cos, acos, sqrt\n",
    "\n",
    "# importing QISKit\n",
    "from qiskit import Aer, IBMQ\n",
    "from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute\n",
    "from qiskit.tools.visualization import plot_histogram\n",
    "from qiskit.tools.monitor import job_monitor\n",
    "from qiskit.providers.ibmq import least_busy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "IBMQ.load_accounts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We prepare the controlled-Hadamard and controlled-u3 gates that are required in the encoding as below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def ch(qProg, a, b):\n",
    "    \"\"\" Controlled-Hadamard gate \"\"\"\n",
    "    qProg.h(b)\n",
    "    qProg.sdg(b)\n",
    "    qProg.cx(a, b)\n",
    "    qProg.h(b)\n",
    "    qProg.t(b)\n",
    "    qProg.cx(a, b)\n",
    "    qProg.t(b)\n",
    "    qProg.h(b)\n",
    "    qProg.s(b)\n",
    "    qProg.x(b)\n",
    "    qProg.s(a)\n",
    "    return qProg\n",
    "\n",
    "def cu3(qProg, theta, phi, lambd, c, t):\n",
    "    \"\"\" Controlled-u3 gate \"\"\"\n",
    "    qProg.u1((lambd-phi)/2, t)\n",
    "    qProg.cx(c, t)\n",
    "    qProg.u3(-theta/2, 0, -(phi+lambd)/2, t)\n",
    "    qProg.cx(c, t)\n",
    "    qProg.u3(theta/2, phi, 0, t)\n",
    "    return qProg"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Encoding 7 bits into 2 qubits with $(7,2)$-QRAC\n",
    "\n",
    "The sender prepares the state to be sent by working on 3 qubits and uses the first one to control the mixture. She needs controlled unitary gates of $(3,1)$-QRAC encoding for her first 6 bits. When the first qubit is zero, she encodes $x_1x_2x_3$ into the second qubit, and $x_4x_5x_6$ into the third qubit. This can be realized with NOT on the first qubit followed by controlled $(3,1)$-QRAC gates with the first qubit as control and the second and third qubits as targets.\n",
    "\n",
    "To encode $x_7$, when $x_7 = 0$ the sender applies a controlled Hadamard on the second qubit (with the first qubit as control), and apply Toffoli gate on the third qubit using the first and second qubits as controls. When $x_7 = 1$, the sender flips the second and third qubits before applying the same operations as when $x_7 = 0$. \n",
    "\n",
    "The decoding operations are the same as those of $(3,1)$-QRAC, and for encoding $x_7$, the receiver just measures the value of the second and third qubit on the computational basis.  \n",
    "\n",
    "Below is the quantum circuits for encoding `\"0101010\"` and decoding any one bit with $(7,2)$-QRAC.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "List of circuit names: ['Encode0101010DecodeFirst', 'Encode0101010DecodeSecond', 'Encode0101010DecodeThird', 'Encode0101010DecodeFourth', 'Encode0101010DecodeFifth', 'Encode0101010DecodeSixth', 'Encode0101010DecodeSeventh']\n"
     ]
    }
   ],
   "source": [
    "#CHANGE THIS 7BIT 0-1 STRING TO PERFORM EXPERIMENT ON ENCODING 0000000, ..., 1111111\n",
    "x1234567 = \"0101010\"\n",
    "\n",
    "if len(x1234567) != 7 or not(\"1\" in x1234567 or \"0\" in x1234567):\n",
    "    raise Exception(\"x1234567 is a 7-bit 0-1 pattern. Please set it to the correct pattern\")\n",
    "    \n",
    "#compute the value of rotation angle theta of (3,1)-QRAC \n",
    "theta = acos(sqrt(0.5 + sqrt(3.0)/6.0))\n",
    "\n",
    "#to record the u3 parameters for encoding 000, 010, 100, 110, 001, 011, 101, 111\n",
    "rotationParams = {\"000\":(2*theta, pi/4, -pi/4), \"010\":(2*theta, 3*pi/4, -3*pi/4), \n",
    "                  \"100\":(pi-2*theta, pi/4, -pi/4), \"110\":(pi-2*theta, 3*pi/4, -3*pi/4), \n",
    "                  \"001\":(2*theta, -pi/4, pi/4), \"011\":(2*theta, -3*pi/4, 3*pi/4), \n",
    "                  \"101\":(pi-2*theta, -pi/4, pi/4), \"111\":(pi-2*theta, -3*pi/4, 3*pi/4)}\n",
    "\n",
    "\n",
    "# Creating registers\n",
    "# qubits for encoding 7 bits of information with qr[0] kept by the sender\n",
    "qr = QuantumRegister(3)\n",
    "# bits for recording the measurement of the qubits qr[1] and qr[2]\n",
    "cr = ClassicalRegister(2)\n",
    "\n",
    "encodingName = \"Encode\"+x1234567\n",
    "encodingCircuit = QuantumCircuit(qr, cr, name=encodingName)\n",
    "\n",
    "#Prepare superposition of mixing QRACs of x1...x6 and x7\n",
    "encodingCircuit.u3(1.187, 0, 0, qr[0])\n",
    "\n",
    "#Encoding the seventh bit\n",
    "seventhBit = x1234567[6]\n",
    "if seventhBit == \"1\":  #copy qr[0] into qr[1] and qr[2]\n",
    "    encodingCircuit.cx(qr[0], qr[1])\n",
    "    encodingCircuit.cx(qr[0], qr[2])\n",
    "    \n",
    "#perform controlled-Hadamard qr[0], qr[1], and toffoli qr[0], qr[1] , qr[2]\n",
    "encodingCircuit = ch(encodingCircuit, qr[0], qr[1])\n",
    "encodingCircuit.ccx(qr[0], qr[1], qr[2])\n",
    "#End of encoding the seventh bit\n",
    "\n",
    "#encode x1...x6 with two (3,1)-QRACS. To do that, we must flip q[0] so that the controlled encoding is executed\n",
    "encodingCircuit.x(qr[0])\n",
    "\n",
    "#Encoding the first 3 bits 000, ..., 111 into the second qubit, i.e., (3,1)-QRAC on the second qubit\n",
    "firstThreeBits = x1234567[0:3]\n",
    "#encodingCircuit.cu3(*rotationParams[firstThreeBits], qr[0], qr[1])\n",
    "encodingCircuit = cu3(encodingCircuit, *rotationParams[firstThreeBits], qr[0], qr[1])\n",
    "\n",
    "#Encoding the second 3 bits 000, ..., 111 into the third qubit, i.e., (3,1)-QRAC on the third qubit\n",
    "secondThreeBits = x1234567[3:6]\n",
    "#encodingCircuit.cu3(*rotationParams[secondTreeBits], qr[0], qr[2])\n",
    "encodingCircuit = cu3(encodingCircuit, *rotationParams[secondThreeBits], qr[0], qr[2])\n",
    "\n",
    "#end of encoding\n",
    "encodingCircuit.barrier()\n",
    "\n",
    "# dictionary for decoding circuits\n",
    "decodingCircuits = {}\n",
    "# Quantum circuits for decoding the 1st to 6th bits\n",
    "for i, pos in enumerate([\"First\", \"Second\", \"Third\", \"Fourth\", \"Fifth\", \"Sixth\"]):\n",
    "    circuitName = \"Decode\"+pos\n",
    "    decodingCircuits[circuitName] = QuantumCircuit(qr, cr, name=circuitName)\n",
    "    if i < 3: #measure 1st, 2nd, 3rd bit\n",
    "        if pos == \"Second\": #if pos == \"First\" we can directly measure\n",
    "            decodingCircuits[circuitName].h(qr[1])\n",
    "        elif pos == \"Third\":\n",
    "            decodingCircuits[circuitName].u3(pi/2, -pi/2, pi/2, qr[1])\n",
    "        decodingCircuits[circuitName].measure(qr[1], cr[1])\n",
    "    else: #measure 4th, 5th, 6th bit\n",
    "        if pos == \"Fifth\": #if pos == \"Fourth\" we can directly measure\n",
    "            decodingCircuits[circuitName].h(qr[2])\n",
    "        elif pos == \"Sixth\":\n",
    "            decodingCircuits[circuitName].u3(pi/2, -pi/2, pi/2, qr[2])\n",
    "        decodingCircuits[circuitName].measure(qr[2], cr[1])\n",
    "\n",
    "        #Quantum circuits for decoding the 7th bit\n",
    "decodingCircuits[\"DecodeSeventh\"] = QuantumCircuit(qr, cr, name=\"DecodeSeventh\")\n",
    "decodingCircuits[\"DecodeSeventh\"].measure(qr[1], cr[0])\n",
    "decodingCircuits[\"DecodeSeventh\"].measure(qr[2], cr[1])\n",
    "\n",
    "#combine encoding and decoding of (7,2)-QRACs to get a list of complete circuits\n",
    "circuitNames = []\n",
    "circuits = []\n",
    "k1 = encodingName\n",
    "for k2 in decodingCircuits.keys():\n",
    "    circuitNames.append(k1+k2)\n",
    "    circuits.append(encodingCircuit+decodingCircuits[k2])\n",
    "\n",
    "print(\"List of circuit names:\", circuitNames) #list of circuit names\n",
    "\n",
    "# for circuit in circuits: #list qasms codes\n",
    "#     print(circuit.qasm())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Below are plots of the experimental results of extracting the first to sixth bit, that results in observing the-$i$th bit with probability at least $0.54$ "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Use the qasm simulator\n",
    "backend = Aer.get_backend(\"qasm_simulator\")\n",
    "\n",
    "# Use the IBM Quantum Experience\n",
    "#backend = least_busy(IBMQ.backends(simulator=False))\n",
    "shots = 1000\n",
    "job = execute(circuits, backend=backend, shots=shots)\n",
    "#job_monitor(job)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Experimental Result of  Encode0101010DecodeFirst\n",
      "Experimental Result of  Encode0101010DecodeSecond\n",
      "Experimental Result of  Encode0101010DecodeThird\n",
      "Experimental Result of  Encode0101010DecodeFourth\n",
      "Experimental Result of  Encode0101010DecodeFifth\n",
      "Experimental Result of  Encode0101010DecodeSixth\n"
     ]
    }
   ],
   "source": [
    "results = job.result()\n",
    "for k in [\"DecodeFirst\", \"DecodeSecond\", \"DecodeThird\", \"DecodeFourth\", \"DecodeFifth\", \"DecodeSixth\"]:\n",
    "    print(\"Experimental Result of \", encodingName+k)\n",
    "    plot_histogram(results.get_counts(circuits[circuitNames.index(encodingName+k)]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The seventh bit is obtained by looking at the content of classical registers. If they are the same, i.e., both are `1` or `0`, then we conclude that it is `0`, or otherwise `1`. For the encoding of `0101010`, the seventh bit is `0`, so the total probability of observing `00` and `11` must exceed that of observing `01` and `10`. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Experimental result of  Encode0101010DecodeSeventh\n"
     ]
    },
    {
     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V8/etfZ+zYsXTp0oVXXnmFnJwcqqurmThxIueccw4XX3xxgquX1khHmiKSsrKzs9m6dWv9523btpGdnV3/+eOPP6asrIxrrrmGESNGsHr1aiZPnlzfGeiYvLw8unfvTllZGRAcsQJkZWVx9dVXU1xcnICtkbZAoSkiKWvkyJFUVFRQWVlJTU0NixYtYty4cfXze/bsycaNGyktLaW0tJRRo0bxy1/+koKCAiorK6mtrQXggw8+YMOGDeTm5nLgwAH2798PwIEDB3j99dfJz89PyvZJ66PTsyKSstLT05kxYwaTJk2irq6OyZMnk5+fz/Tp0ykoKGD8+PFNLvv2228za9YsOnbsSIcOHXj00UfJzMxk06ZN3HzzzQDU1tYyadIkxo4dm6hNklbO3D3ZNSRNQUGBL1u2LNlliIhICsnIyCh291GNzUv46Vkzu9vM3jezw2ZWbGZjQi432sxqzWxdg+lfMzNv5NWlqXWJiIicioSGppndCDwOTAcKgBXAEjPLPclyvYDngP9qoslBIDv65e6H41W3iIgIJP5Icxow193nuHuZu98DVAF3nWS5nwPPAiubmO/uvj36FceaRUREgASGppl1AgqB1xrMeg1ocoCUmd0N9AF+0Mzqu5pZpZltMbPFZlZw2gWLiIg0kMjes72BNGBHg+k7gEa7rpnZcOAh4EJ3r2viNljlwG1AKdADmAq8ZWYj3H1DI+u8A7gDgjFga9asAYJxW926dWPjxo0AnHHGGQwaNKh+vFdaWhojRoygvLycAwcOAMG9LXfv3s2OHcEm9evXj06dOlFRUQFAr169yM3NpbS0FICOHTsyfPhwysrKOHToEABDhw6lurqa6upqAPr374+ZsWnTJgAyMzPJzs5m3brgUm7nzp0577zzePfddzly5AgAw4YNo6qqil27dgEwYMAA3J3KykogGIuWlZXF+vXrAejatSv5+fmsXbuWo0ePAsENrDdv3syePXsAGDRoEDU1NWzZsgWAPn36kJGRUT/OrXv37uTl5VFaWkpdXR0ABQUFVFRUsHfvXgAGDx7MwYMH2bZtG8f+vXv27El5eTkAPXr0YMiQIZSUlODumBkFBQVs2LChfkhAXl4e+/btq78Lj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yucff1kfkPAW8DGyJt7iUIzUZ75IqIiJyqhIamu//azDKBBwjGU64DJrh7ZaRJY+M1Sxp8vgaoBAZEPp8JzAbOAvZG2he5+6r4Vi8iIu1doo80cfengKeamPf5RqbZSdb3TeCbcSlORESkGbr3rIiISEgKTRERkZAUmiIiIiEpNEVEREJSaIqIiISk0BQREQlJoSkiIhKSQlNERCQkhaaIiEhICk0REZGQFJoiIiIhKTRFRERCUmiKiIiEpNAUEREJSaEpIiISkkJTREQkJIWmiIhISApNERGRkBSaIiIiISk0RUREQlJoioiIhKTQFBERCUmhKSIiEpJCU0REJCSFpoiISEgKTRERkZAUmiIiIiEpNEVEREJSaIqIiISk0BQREQlJoSkiIhKSQlNERCQkhaaIiEhICk0REZGQFJoiIiIhKTRFRERCUmiKiIiEpNAUEREJSaEpIiISkkJTREQkJIWmiIhISApNkYilS5dywQUXUFhYyKxZs06Yf+TIEW677TYKCwsZO3YsmzdvBqC4uJiioiKKiooYM2YMixcvrl/mqaee4qKLLuLiiy/m9ttv5/DhwwnbHhGJP4WmCFBXV8f999/PggULWLlyJQsXLuS99947rs38+fM588wzKS4u5q677uLhhx8GID8/n2XLlrF8+XJeeOEFpk2bRm1tLdu2bWP27NksW7aMFStWUFdXx6JFi5KwdSISLwpNEYKjxYEDBzJgwAA6derExIkTWbJkyXFtXnnlFW666SYArrvuOpYvX467061bN9LT04HgaNTM6pepra3l8OHD1NbWcujQIc4666zEbZSIxJ1CUwSoqqqib9++9Z9zcnKoqqpqsk16ejo9e/Zk9+7dAKxevZqLLrqI0aNHM3PmTNLT08nJyeEb3/gG559/Pvn5+fTs2ZPLL788cRslInGn0BSJg1GjRrFy5UqWLl3KrFmzOHz4MB999BFLliyhpKSE9evXc/DgQRYsWJDsUkXkNCg0RYDs7Gy2bt1a/3nbtm1kZ2c32aa2tpZ9+/aRkZFxXJu8vDy6d+9OWVkZv//978nNzaV379507NiRL37xi6xatarlN0ZEWoxCUwQYOXIkFRUVVFZWUlNTw6JFixg3btx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ByJfC3xP0ml2ctGLbucgvml8juFb2WWA/wbX//wZ+5O6t7lRga9ZUb2Uz6wasAX7h7q3ucoZCM4WY2VzgPOA/gN0Ep2aHA+cQfGE/oB/8xGpinxQA5xIMbXjU3V9LWoHtmJn1BPZHfzFHjjy7AH8FDCM4M6CfmQRpbJ800qYLQUehf4s8E7lVUWimiMjRyn6CUxbLo6blAv+L4DrAIODL7r4maYW2I83sk37AhQRHl/0Jnu+qfZJgZvY0QQ/NVQTjAU8YG2tmvdx9j8ZoJkbIfXKmu3+U8OLiRL1nU8dQ4H2C4SZAcP7f3SvdfQFwDcGp2r9JUn3tUVP75AN3f4HgWtl+tE8Szsy+QvBLy0zgJYLhDBPNbHDkehpm9lfAL8xsuAKz5TWxT643s89E7ZOuwLPHhtO1RjrSTBGR/0yLCW5ccAvwl4a3yDOze4C/c/fPJqHEdkf7JHWZ2RygDpgBTASmAJ8ByoFXgP8iuOHB4+7eKVl1tiftZZ/oSDNFRO5p+n+ArsBzwC1mdnbkt+VjF88vJRiTJgmgfZKaImMz3wc+cvcKd/8Xdx8OfI7gtnlTCIZpPYFuapAQ7Wmf6EgzxUROW3wPuJbgRu0rgWqCe89WAbe7+9rkVdj+aJ+knsi9gPtE7inbCTjaoEPQjQS3NBzp7n9KVp3tSXvZJwrNFBUZ6nA18CWCbvPrgBfc/b2kFtaOaZ+ktkjPWXP3OjP7e4LTgN2SXVd71hb3iUKzFTA9AizlaJ+kNjObBqS5+6PJrkUCbWWfKDRFpM2JPDmjTr/YpI62sk8UmiIiIiGp96yIiEhICk0REZGQFJoiIiIhKTRFRERCUmiKiIiEpNAUEREJ6X8A8MUcTG2DQ7YAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 504x360 with 1 Axes>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"Experimental result of \", encodingName+\"DecodeSeventh\")\n",
    "plot_histogram(results.get_counts(circuits[circuitNames.index(encodingName+\"DecodeSeventh\")]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can experiment with other seven-bit encodings by changing the value `x1234567` in the code above, and see that in any case we can decode the correct bit with probability strictly better than random guessing. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## About Quantum Random Access Coding\n",
    "The success probability $(7,2)$-QRAC shown above is not high due to the use of mixed states. There exists a better code using pure states as shown [here](https://arxiv.org/abs/1607.02667), where the success probability becomes $0.68$. [The paper](https://arxiv.org/abs/1607.02667) also shows the construction of $(n,2)$-QRACs with pure states for $n=7,\\ldots,12$. It is still open if there is a coding scheme with only pure states for $n=13, 14, 15$. Notice that $(n, m)$-QRACs exist for $ n \\le 2^{2m}-1$ that can be realized with mixed states as shown [here](http://link.springer.com/chapter/10.1007/978-3-540-73420-8_12)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
